import Vue from 'vue'
import { IS_PROD as isProduction } from '@/shared/consts'
import tempPageData from './_utils/tempPageData'
import isWxBrowser from './_utils/isWxBrowser'
import isDingTalk from './_utils/isDingTalk'
import checkIdCard from './_utils/checkIdCard'

import { http } from './http'

const utils = {
  tempPageData,
  pLog(msg, additions=null) {
    if (!isProduction) {
      console.log('%c♯♯♯♯♯-- APP: %c%s %o%c -----♯', 'color:green', 'color:blue', msg, additions, 'color:green')
    }
  },
  toastWithCb(conf, cb) {
    uni.showToast(conf)
    if (conf.duration > 0 && typeof cb === 'function') {
      setTimeout(cb, conf.duration)
    }
  },

  isWxBrowser,
  isDingTalk,
  
  // 手机号格式是否正确
  isMobilePhone(value) {
    const reg = /^1\d{10}$/
    if (reg.test(value)) {
      return true
    }
    return false
  },
  isIdCardNumber(value) {
    return checkIdCard(value)
  },
  
}

Vue.prototype.$utils = utils

export default utils
